import { PageReq } from "@/typings/api";
import { CodeGenerate, CreateCodeGenerateReq, UpdateCodeGenerateReq } from "@/typings/api/codeGenerate";
import { request } from "@/utils/request";

export const getCodeGenerateList = (params: PageReq<CodeGenerate>) => request.get("/codeGenerate", { params });
export const getCodeGenerateRecord = (_id: string) => request.get(`/codeGenerate/${_id}`);
export const createCodeGenerate = (data: CreateCodeGenerateReq) => request.post("/codeGenerate", data);
export const updateCodeGenerate = (data: UpdateCodeGenerateReq) => request.put("/codeGenerate", data);
export const deleteCodeGenerate = (_id: string) => request.delete("/codeGenerate", { data: { _id } });
export const downloadCodeGenerate = (_id: string) =>
    request.get("/codeGenerate/downloadCode", { params: { _id }, responseType: "blob" }) as Promise<Blob>;
export const viewCodeGenerate = (_id: string) => request.get("/codeGenerate/viewCode", { params: { _id } });
export const generatePermissions = (_id: string) => request.post("/codeGenerate/generagePermissions", { _id });